package com.kapcb.statemachine;

import com.kapcb.statemachine.impl.TransitionType;

/**
 * <a>Title: Transition </a>
 * <a>Author: Kapcb <a>
 * <a>Description: Transition <a>
 *
 * @author Kapcb
 * @version 1.0
 * @date 2024/7/13 22:14
 * @since 1.0
 */
public interface Transition<S, E, C> {

    /**
     * Gets the source state of this transition.
     *
     * @return the source state
     */
    State<S, E, C> getSource();

    void setSource(State<S, E, C> state);

    E getEvent();

    void setEvent(E event);

    void setType(TransitionType type);

    void setTarget(State<S, E, C> state);

    /**
     * Gets the target state of this transition.
     *
     * @return the target state
     */
    State<S, E, C> getTarget();

    /**
     * Gets the guard of this transition.
     *
     * @return the guard
     */
    Condition<C> getCondition();

    void setCondition(Condition<C> condition);

    Action<S, E, C> getAction();

    void setAction(Action<S, E, C> action);

    /**
     * Do transition from source state to target state.
     *
     * @return the target state
     */
    State<S, E, C> transit(C ctx, boolean checkCondition);

    /**
     * Verify transition correctness
     */
    void verify();
}
